package cn.gson.crm.model.pojos;

import javax.persistence.*;
import java.sql.Time;
import java.util.Date;
import java.sql.Timestamp;
import java.util.List;
import java.util.Objects;

@Entity
@Table(name = "USER_", schema = "CRM", catalog = "")
public class User {
    private Integer yId;
    private String yPwd;
    private String yName;
    private Timestamp yTime;
    private String yJob;
    private Long deptId;
    private String ySex;
    private String yAge;
    private String yAffress;
    private String yProvince;
    private String yCity;
    private String yArea;
    private Long yPhone;
    private Dept dept;
    private String ySrc;
    private String yDizhishuzi;
    private List<Role> roleList;
    private List<Employee> employees;
    @OneToMany(mappedBy = "user")
    public List<Employee> getEmployees() {
        return employees;
    }

    public void setEmployees(List<Employee> employees) {
        this.employees = employees;
    }

    @Column(name="Y_DIZHISHUZI")
    public String getyDizhishuzi() {
        return yDizhishuzi;
    }

    public void setyDizhishuzi(String yDizhishuzi) {
        this.yDizhishuzi = yDizhishuzi;
    }

    @ManyToMany
    @JoinTable(name = "user_role",
            joinColumns = {
                    @JoinColumn(name="y_id")
            },
            inverseJoinColumns = {
                    @JoinColumn(name = "j_id")
            })
    public List<Role> getRoleList() {
        return roleList;
    }

    public void setRoleList(List<Role> roleList) {
        this.roleList = roleList;
    }

    @Basic
    @Column(name = "y_src", nullable = true, length = 1024)
    public String getySrc() {
        return ySrc;
    }

    public void setySrc(String ySrc) {
        this.ySrc = ySrc;
    }

    @ManyToOne
    @JoinColumn(name = "DEPT_ID",insertable = false,updatable = false)
    public Dept getDept() {
        return dept;
    }

    public void setDept(Dept dept) {
        this.dept = dept;
    }

    @Id
    @Column(name = "Y_ID", nullable = false, precision = 0)
    @GeneratedValue(generator = "seq",strategy = GenerationType.SEQUENCE)
    //定义一个序列生成器
    @SequenceGenerator(name = "seq",sequenceName = "crm",
            initialValue = 1,allocationSize = 1)
    public Integer getyId() {
        return yId;
    }

    public void setyId(Integer yId) {
        this.yId = yId;
    }

    @Basic
    @Column(name = "Y_PWD", nullable = true, length = 1024)
    public String getyPwd() {
        return yPwd;
    }

    public void setyPwd(String yPwd) {
        this.yPwd = yPwd;
    }

    @Basic
    @Column(name = "Y_NAME", nullable = true, length = 1024)
    public String getyName() {
        return yName;
    }

    public void setyName(String yName) {
        this.yName = yName;
    }

    @Basic
    @Column(name = "Y_TIME", nullable = true)
    public Timestamp getyTime() {
        return yTime;
    }

    public void setyTime(Timestamp yTime) {
        this.yTime = yTime;
    }

    @Basic
    @Column(name = "Y_JOB", nullable = true, length = 1024)
    public String getyJob() {
        return yJob;
    }

    public void setyJob(String yJob) {
        this.yJob = yJob;
    }

    @Basic
    @Column(name = "DEPT_ID", nullable = true, precision = 0)
    public Long getDeptId() {
        return deptId;
    }

    public void setDeptId(Long deptId) {
        this.deptId = deptId;
    }

    @Basic
    @Column(name = "Y_SEX", nullable = true, length = 244)
    public String getySex() {
        return ySex;
    }

    public void setySex(String ySex) {
        this.ySex = ySex;
    }

    @Basic
    @Column(name = "Y_AGE", nullable = true, length = 255)
    public String getyAge() {
        return yAge;
    }

    public void setyAge(String yAge) {
        this.yAge = yAge;
    }

    @Basic
    @Column(name = "Y_AFFRESS", nullable = true, length = 255)
    public String getyAffress() {
        return yAffress;
    }

    public void setyAffress(String yAffress) {
        this.yAffress = yAffress;
    }

    @Basic
    @Column(name = "Y_PROVINCE", nullable = true, length = 255)
    public String getyProvince() {
        return yProvince;
    }

    public void setyProvince(String yProvince) {
        this.yProvince = yProvince;
    }

    @Basic
    @Column(name = "Y_CITY", nullable = true, length = 255)
    public String getyCity() {
        return yCity;
    }

    public void setyCity(String yCity) {
        this.yCity = yCity;
    }

    @Basic
    @Column(name = "Y_AREA", nullable = true, length = 255)
    public String getyArea() {
        return yArea;
    }

    public void setyArea(String yArea) {
        this.yArea = yArea;
    }

    @Basic
    @Column(name = "Y_PHONE", nullable = true, precision = 0)
    public Long getyPhone() {
        return yPhone;
    }

    public void setyPhone(Long yPhone) {
        this.yPhone = yPhone;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        User user = (User) o;
        return yId == user.yId &&
                Objects.equals(yPwd, user.yPwd) &&
                Objects.equals(yName, user.yName) &&
                Objects.equals(yTime, user.yTime) &&
                Objects.equals(yJob, user.yJob) &&
                Objects.equals(deptId, user.deptId) &&
                Objects.equals(ySex, user.ySex) &&
                Objects.equals(yAge, user.yAge) &&
                Objects.equals(yAffress, user.yAffress) &&
                Objects.equals(yProvince, user.yProvince) &&
                Objects.equals(yCity, user.yCity) &&
                Objects.equals(yArea, user.yArea) &&
                Objects.equals(yPhone, user.yPhone);
    }

    @Override
    public int hashCode() {
        return Objects.hash(yId, yPwd, yName, yTime, yJob, deptId, ySex, yAge, yAffress, yProvince, yCity, yArea, yPhone);
    }
}
